<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>用户管理系统</title>
  <link href="../static/css/bootstrap.min.css" rel="stylesheet">
  <link rel="stylesheet" href="../static/bootstrap-icons/font/bootstrap-icons.css">
  <style>
    :root {
      --primary-color: #4361ee;
      --secondary-color: #3f37c9;
      --accent-color: #4895ef;
      --light-color: #f8f9fa;
      --dark-color: #212529;
      --success-color: #4cc9f0;
      --warning-color: #f8961e;
      --danger-color: #f72585;
      --border-radius: 8px;
      --box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
      --border-color: #e0e0e0;
    }

    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    body {
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      background-color: #f5f7fa;
      color: var(--dark-color);
      line-height: 1.6;
      padding: 20px;
    }

    .container {
      max-width: 1400px;
      margin: 0 auto;
      background: white;
      border-radius: var(--border-radius);
      box-shadow: var(--box-shadow);
      overflow: hidden;
    }

    /* 工具栏样式 */
    .toolbar {
      display: flex;
      flex-wrap: wrap;
      gap: 15px;
      padding: 20px;
      background: white;
      border-bottom: 1px solid var(--border-color);
      align-items: center;
    }

    .btn {
      padding: 10px 20px;
      border: none;
      border-radius: var(--border-radius);
      cursor: pointer;
      font-size: 14px;
      transition: all 0.3s;
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .btn-primary {
      background-color: var(--primary-color);
      color: white;
    }

    .btn-primary:hover {
      background-color: var(--secondary-color);
    }

    .btn-search {
      background-color: var(--success-color);
      color: white;
    }

    .btn-search:hover {
      background-color: #3ab7d8;
    }

    .search-group {
      display: flex;
      flex-wrap: wrap;
      gap: 10px;
      flex: 1;
      min-width: 200px;
    }

    .form-control {
      padding: 10px 15px;
      border: 1px solid var(--border-color);
      border-radius: var(--border-radius);
      font-size: 14px;
      transition: all 0.3s;
      min-width: 150px;
    }

    .form-control:focus {
      border-color: var(--primary-color);
      box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
      outline: none;
    }

    /* 统计卡片样式 */
    .stats-container {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
      gap: 20px;
      padding: 20px;
    }

    .stat-card {
      background: white;
      border-radius: var(--border-radius);
      box-shadow: var(--box-shadow);
      padding: 20px;
      display: flex;
      flex-direction: column;
      align-items: center;
      text-align: center;
    }

    .stat-icon {
      font-size: 40px;
      margin-bottom: 15px;
    }

    .stat-value {
      font-size: 32px;
      font-weight: bold;
      margin-bottom: 5px;
    }

    .stat-label {
      color: #6c757d;
      font-size: 14px;
    }

    .stat-card.total-users {
      border-top: 4px solid var(--primary-color);
    }

    .stat-card.owners {
      border-top: 4px solid var(--accent-color);
    }

    .stat-card.favorites {
      border-top: 4px solid var(--success-color);
    }

    .stat-card.checkins {
      border-top: 4px solid var(--warning-color);
    }

    /* 表格样式 */
    .table-container {
      width: 100%;
      overflow-x: auto;
    }

    .data-table {
      width: 100%;
      border-collapse: collapse;
    }

    .data-table thead {
      background-color: var(--primary-color);
      color: white;
    }

    .data-table th {
      padding: 15px;
      text-align: center;
      font-weight: 500;
      font-size: 14px;
      text-transform: uppercase;
      letter-spacing: 0.5px;
    }

    .data-table tbody tr {
      border-bottom: 1px solid var(--border-color);
      transition: all 0.2s ease;
    }

    .data-table tbody tr:hover {
      background-color: rgba(67, 97, 238, 0.05);
    }

    .data-table td {
      padding: 15px;
      color: #495057;
      font-size: 14px;
      text-align: center;
      vertical-align: middle;
    }

    /* 操作按钮样式 - 修复部分 */
    .btn-view, .btn-edit, .btn-delete {
      padding: 8px 12px;
      margin: 2px;
      font-size: 12px;
      border-radius: 4px;
      border: none;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
      gap: 4px;
      transition: all 0.2s ease;
    }

    .btn-view {
      background-color: var(--success-color);
      color: white;
    }

    .btn-edit {
      background-color: var(--accent-color);
      color: white;
    }

    .btn-delete {
      background-color: var(--danger-color);
      color: white;
    }

    .btn-view:hover, .btn-edit:hover, .btn-delete:hover {
      opacity: 0.9;
      transform: translateY(-1px);
    }

    /* 分页器样式 */
    .pagination-controls {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 20px;
      background: white;
      border-top: 1px solid var(--border-color);
    }

    .page-size-selector {
      display: flex;
      align-items: center;
      gap: 10px;
    }

    .page-size-selector label {
      font-size: 14px;
    }

    .pagination {
      display: flex;
      align-items: center;
      gap: 5px;
    }

    .page-btn {
      width: 36px;
      height: 36px;
      display: flex;
      align-items: center;
      justify-content: center;
      border: 1px solid var(--border-color);
      border-radius: 4px;
      background: none;
      cursor: pointer;
      transition: all 0.2s;
    }

    .page-btn:hover {
      border-color: var(--primary-color);
      color: var(--primary-color);
    }

    .page-btn.active {
      background-color: var(--primary-color);
      border-color: var(--primary-color);
      color: white;
    }

    .page-btn.disabled {
      opacity: 0.5;
      cursor: not-allowed;
    }

    .page-numbers {
      display: flex;
      gap: 5px;
    }

    /* 用户头像样式 */
    .user-avatar {
      width: 50px;
      height: 50px;
      object-fit: cover;
      border-radius: 50%;
      border: 2px solid #e0e0e0;
    }

    .user-avatar-placeholder {
      width: 50px;
      height: 50px;
      border-radius: 50%;
      background-color: #e9ecef;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 20px;
      color: #adb5bd;
    }

    /* 状态标签 */
    .status-badge {
      padding: 6px 12px;
      border-radius: 12px;
      font-size: 12px;
      font-weight: 500;
    }

    .status-owner {
      background-color: #d4edda;
      color: #155724;
    }

    .status-user {
      background-color: #e2e3e5;
      color: #383d41;
    }

    /* 提示框样式 */
    .alert {
      position: fixed;
      top: 20px;
      left: 50%;
      transform: translateX(-50%);
      padding: 15px 20px;
      border-radius: 4px;
      display: none;
      align-items: center;
      z-index: 1000;
      max-width: 80%;
      animation: slideIn 0.3s ease-out forwards;
    }

    .alert-success {
      background-color: #d4edda;
      color: #155724;
      border: 1px solid #c3e6cb;
    }

    .alert-danger {
      background-color: #f8d7da;
      color: #721c24;
      border: 1px solid #f5c6cb;
    }

    .alert i {
      margin-right: 10px;
      font-size: 18px;
    }

    .alert-close {
      margin-left: 15px;
      background: none;
      border: none;
      color: inherit;
      font-size: 20px;
      cursor: pointer;
    }

    @keyframes slideIn {
      from {
        opacity: 0;
        transform: translate(-50%, -30px);
      }
      to {
        opacity: 1;
        transform: translate(-50%, 0);
      }
    }

    @keyframes spin {
      to { transform: rotate(360deg); }
    }

    /* 加载动画 */
    #compact-loader {
      position: fixed;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      width: 240px;
      padding: 12px;
      background: rgba(0,0,0,0.85);
      border-radius: 8px;
      display: none;
      align-items: center;
      z-index: 9999;
      color: white;
      font-family: sans-serif;
    }

    .spinner {
      width: 24px;
      height: 24px;
      border: 3px solid rgba(255,255,255,0.2);
      border-top-color: #3498db;
      border-radius: 50%;
      animation: spin 1s linear infinite;
      margin-right: 12px;
    }

    .form-control {
      width: auto;
    }
    /* 模态框样式 */
    .modal-overlay {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background-color: rgba(0, 0, 0, 0.5);
      display: none;
      justify-content: center;
      align-items: center;
      z-index: 2000;
      padding: 20px;
    }

    .modal-content {
      background-color: white;
      border-radius: var(--border-radius);
      box-shadow: var(--box-shadow);
      width: 100%;
      max-width: 700px;
      max-height: 90vh;
      overflow-y: auto;
      animation: modalFadeIn 0.3s ease-out;
    }

    @keyframes modalFadeIn {
      from {
        opacity: 0;
        transform: translateY(-30px);
      }
      to {
        opacity: 1;
        transform: translateY(0);
      }
    }

    .modal-header {
      padding: 20px 25px;
      border-bottom: 1px solid var(--border-color);
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    .modal-title {
      font-size: 20px;
      font-weight: 600;
      color: var(--dark-color);
    }

    .modal-close {
      background: none;
      border: none;
      font-size: 24px;
      cursor: pointer;
      color: #6c757d;
      transition: color 0.2s;
    }

    .modal-close:hover {
      color: var(--danger-color);
    }

    .modal-body {
      padding: 25px;
    }

    .modal-footer {
      padding: 20px 25px;
      border-top: 1px solid var(--border-color);
      display: flex;
      justify-content: flex-end;
      gap: 10px;
    }

    /* 用户详情样式 */
    .user-detail-container {
      display: grid;
      grid-template-columns: 1fr 2fr;
      gap: 30px;
    }

    .user-avatar-large-placeholder {
      width: 150px;
      height: 150px;
      border-radius: 50%;
      background-color: #e9ecef;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 50px;
      color: #adb5bd;
      margin: 0 auto;
      border: 4px solid var(--primary-color);
    }

    .user-info-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 20px;
    }

    .info-item {
      margin-bottom: 15px;
    }

    .info-label {
      font-weight: 600;
      color: #6c757d;
      margin-bottom: 5px;
      font-size: 14px;
    }

    .info-value {
      font-size: 16px;
      color: var(--dark-color);
    }

    .user-stats {
      display: flex;
      justify-content: space-between;
      margin-top: 20px;
      padding-top: 20px;
      border-top: 1px solid var(--border-color);
    }

    .stat-item {
      text-align: center;
    }

    .stat-number {
      font-size: 24px;
      font-weight: 700;
      color: var(--primary-color);
    }

    .stat-label {
      font-size: 14px;
      color: #6c757d;
    }

    /* 响应式调整 */
    @media (max-width: 768px) {
      .user-detail-container {
        grid-template-columns: 1fr;
        gap: 20px;
      }

      .user-info-grid {
        grid-template-columns: 1fr;
      }

      .user-stats {
        flex-direction: column;
        gap: 15px;
      }

      .modal-content {
        max-width: 95%;
      }
    }
    /* 表单样式 */
    .form-group {
      margin-bottom: 20px;
    }

    .form-label {
      display: block;
      margin-bottom: 8px;
      font-weight: 600;
      color: var(--dark-color);
    }

    .form-input {
      width: 100%;
      padding: 12px 15px;
      border: 1px solid var(--border-color);
      border-radius: var(--border-radius);
      font-size: 16px;
      transition: all 0.3s;
    }

    .form-input:focus {
      border-color: var(--primary-color);
      box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
      outline: none;
    }

    .form-select {
      width: 100%;
      padding: 12px 15px;
      border: 1px solid var(--border-color);
      border-radius: var(--border-radius);
      font-size: 16px;
      background-color: white;
      transition: all 0.3s;
    }

    .form-select:focus {
      border-color: var(--primary-color);
      box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
      outline: none;
    }

    .form-textarea {
      width: 100%;
      padding: 12px 15px;
      border: 1px solid var(--border-color);
      border-radius: var(--border-radius);
      font-size: 16px;
      resize: vertical;
      min-height: 100px;
      transition: all 0.3s;
    }

    .form-textarea:focus {
      border-color: var(--primary-color);
      box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
      outline: none;
    }

    .avatar-upload {
      display: flex;
      flex-direction: column;
      align-items: center;
      margin-bottom: 20px;
    }

    .avatar-preview {
      width: 120px;
      height: 120px;
      border-radius: 50%;
      object-fit: cover;
      border: 3px solid var(--border-color);
      margin-bottom: 15px;
    }

    .avatar-upload-btn {
      background-color: var(--light-color);
      border: 1px solid var(--border-color);
      padding: 8px 15px;
      border-radius: var(--border-radius);
      cursor: pointer;
      transition: all 0.3s;
      display: inline-flex;
      align-items: center;
      gap: 5px;
    }

    .avatar-upload-btn:hover {
      background-color: #e9ecef;
    }

    .required {
      color: var(--danger-color);
    }

    .form-hint {
      font-size: 12px;
      color: #6c757d;
      margin-top: 5px;
    }
    .user-avatar-large-placeholder {
      width: 150px;
      height: 150px;
      border-radius: 50%;  /* 圆形 */
      overflow: hidden;    /* 隐藏超出部分 */
      position: relative;
    }
    .user-avatar-large-placeholder img {
      width: 100%;
      height: 100%;
    }
    #error-alert{
      z-index: 10001 !important;
    }
    /* 添加用户模态框样式 */
    #addUserModal .modal-content {
      max-width: 700px;
      max-height: 90vh;
      overflow-y: auto;
    }

    /* 头像上传区域 */
    .avatar-upload-section {
      margin-bottom: 24px;
      padding: 20px;
      background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
      border-radius: 12px;
      border: 2px dashed #dee2e6;
    }

    .avatar-preview-container {
      display: flex;
      align-items: center;
      gap: 24px;
    }

    .avatar-preview-wrapper {
      position: relative;
      width: 120px;
      height: 120px;
      border-radius: 50%;
      overflow: hidden;
      border: 3px solid var(--primary-color);
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
      cursor: pointer;
      transition: all 0.3s ease;
    }

    .avatar-preview-wrapper:hover {
      transform: scale(1.05);
      box-shadow: 0 6px 20px rgba(67, 97, 238, 0.3);
    }

    .avatar-preview-img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      display: none;
    }

    .avatar-placeholder {
      width: 100%;
      height: 100%;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      color: white;
      text-align: center;
    }

    .avatar-placeholder i {
      font-size: 32px;
      margin-bottom: 8px;
    }

    .avatar-placeholder span {
      font-size: 12px;
      font-weight: 500;
    }

    .avatar-upload-controls {
      flex: 1;
    }

    .avatar-upload-btn {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: 10px 20px;
      background: var(--primary-color);
      color: white;
      border: none;
      border-radius: var(--border-radius);
      cursor: pointer;
      font-weight: 500;
      transition: all 0.3s ease;
      margin-bottom: 8px;
    }

    .avatar-upload-btn:hover {
      background: var(--secondary-color);
      transform: translateY(-1px);
    }

    .avatar-hint {
      font-size: 12px;
      color: #6c757d;
      margin-top: 8px;
    }

    /* 表单分区 */
    .form-section {
      margin-bottom: 24px;
      padding-bottom: 20px;
      border-bottom: 1px solid var(--border-color);
    }

    .form-section:last-of-type {
      border-bottom: none;
      margin-bottom: 0;
    }

    .section-title {
      font-size: 16px;
      font-weight: 600;
      color: var(--dark-color);
      margin-bottom: 16px;
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .section-title::before {
      content: "";
      width: 4px;
      height: 16px;
      background: var(--primary-color);
      border-radius: 2px;
    }

    /* 表单行布局 */
    .form-row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 16px;
      margin-bottom: 16px;
    }

    /* 表单元素增强样式 */
    .form-label {
      display: flex;
      align-items: center;
      gap: 4px;
      margin-bottom: 6px;
      font-weight: 600;
      color: var(--dark-color);
    }

    .required {
      color: var(--danger-color);
      font-size: 14px;
    }

    .form-input, .form-select, .form-textarea {
      width: 100%;
      padding: 12px 16px;
      border: 2px solid var(--border-color);
      border-radius: var(--border-radius);
      font-size: 14px;
      transition: all 0.3s ease;
      background: white;
    }

    .form-input:focus, .form-select:focus, .form-textarea:focus {
      border-color: var(--primary-color);
      box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
      outline: none;
    }

    .form-input:valid:not(:placeholder-shown) {
      border-color: var(--success-color);
    }

    .form-input:invalid:not(:placeholder-shown) {
      border-color: var(--danger-color);
    }

    .form-textarea {
      resize: vertical;
      min-height: 80px;
      line-height: 1.5;
    }

    .form-hint {
      font-size: 12px;
      color: #6c757d;
      margin-top: 4px;
      display: flex;
      align-items: center;
      gap: 4px;
    }

    /* 按钮样式增强 */
    .modal-footer {
      display: flex;
      justify-content: flex-end;
      gap: 12px;
      padding: 20px 24px;
      border-top: 1px solid var(--border-color);
      background: #f8f9fa;
    }

    .btn {
      padding: 10px 24px;
      border: none;
      border-radius: var(--border-radius);
      cursor: pointer;
      font-weight: 500;
      transition: all 0.3s ease;
      display: inline-flex;
      align-items: center;
      gap: 8px;
    }

    .btn-secondary {
      background: #6c757d;
      color: white;
    }

    .btn-secondary:hover {
      background: #5a6268;
      transform: translateY(-1px);
    }

    .btn-primary {
      background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
      color: white;
    }

    .btn-primary:hover {
      background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
      transform: translateY(-1px);
      box-shadow: 0 4px 12px rgba(67, 97, 238, 0.3);
    }

    /* 响应式设计 */
    @media (max-width: 768px) {
      .avatar-preview-container {
        flex-direction: column;
        text-align: center;
      }

      .form-row {
        grid-template-columns: 1fr;
        gap: 12px;
      }

      .modal-footer {
        flex-direction: column-reverse;
      }

      .btn {
        width: 100%;
        justify-content: center;
      }
    }

    @media (max-width: 480px) {
      .avatar-upload-section {
        padding: 16px;
      }

      .avatar-preview-wrapper {
        width: 100px;
        height: 100px;
      }

      .section-title {
        font-size: 15px;
      }
    }

    /* 加载状态 */
    .btn.loading {
      position: relative;
      color: transparent;
    }

    .btn.loading::after {
      content: "";
      position: absolute;
      width: 16px;
      height: 16px;
      border: 2px solid transparent;
      border-top: 2px solid currentColor;
      border-radius: 50%;
      animation: spin 1s linear infinite;
    }

    @keyframes spin {
      0% { transform: rotate(0deg); }
      100% { transform: rotate(360deg); }
    }

    /* 成功状态指示 */
    .form-group.success .form-input,
    .form-group.success .form-select {
      border-color: var(--success-color);
    }

    .form-group.error .form-input,
    .form-group.error .form-select {
      border-color: var(--danger-color);
    }
  </style>
</head>
<body>
<!-- 提示框 -->
<div class="alert alert-danger" id="error-alert" style="display: none;">
  <i class="bi bi-exclamation-circle"></i>
  <span id="error-message">操作失败</span>
  <button class="alert-close">&times;</button>
</div>

<div class="alert alert-success" id="success-alert" style="display: none;">
  <i class="bi bi-check-circle"></i>
  <span id="success-message">操作成功</span>
  <button class="alert-close">&times;</button>
</div>

<div class="container">

  <div class="toolbar">
    <button class="btn btn-primary" id="addCheckinBtn" onclick="openAddUserModal()">
      <i class="bi bi-plus-circle"></i> 添加用户
    </button>
    <div class="search-group">
      <input type="text" class="form-control" id="username" placeholder="请输入用户名">
      <select class="form-control" id="userType">
        <option value="">所有用户</option>
        <option value="1">店主</option>
        <option value="0">普通用户</option>
      </select>
      <button class="btn btn-search" id="searchBtn">
        <i class="bi bi-search"></i> 搜索
      </button>
    </div>
  </div>

  <div class="table-container">
    <table class="data-table">
      <thead>
      <tr>
        <th>ID</th>
        <th>头像</th>
        <th>用户名</th>
        <th>用户类型</th>
        <th>收藏店铺数</th>
        <th>打卡店铺数</th>
        <th>操作</th>
      </tr>
      </thead>
      <tbody id="tableBody">
      <!-- 数据将通过JS动态加载 -->
      </tbody>
    </table>
  </div>

  <div class="pagination-controls">
    <div class="page-size-selector">
      <label for="pageSize">每页显示:</label>
      <select id="pageSize" class="form-control">
        <option value="5">5条</option>
        <option value="10" selected>10条</option>
        <option value="20">20条</option>
        <option value="50">50条</option>
      </select>
    </div>

    <div class="pagination">
      <button class="page-btn" id="prevPage"><i class="bi bi-chevron-left"></i></button>
      <div class="page-numbers" id="pageNumbers">
        <!-- 页码将通过JS动态生成 -->
      </div>
      <button class="page-btn" id="nextPage"><i class="bi bi-chevron-right"></i></button>
    </div>
  </div>
</div>

<!-- 查看用户模态框 -->
<div class="modal-overlay" id="viewUserModal">
  <div class="modal-content">
    <div class="modal-header">
      <h3 class="modal-title">用户详情</h3>
      <button class="modal-close" onclick="closeViewModal()">&times;</button>
    </div>
    <div class="modal-body">
      <div class="user-detail-container">
        <div class="user-avatar-section">
          <div class="user-avatar-large-placeholder">
            <img src=""/>
          </div>
        </div>
        <div class="user-info-section">
          <div class="user-info-grid">
            <div class="info-item">
              <div class="info-label">用户ID</div>
              <div class="info-value" id="viewUserId">1001</div>
            </div>
            <div class="info-item">
              <div class="info-label">用户名</div>
              <div class="info-value" id="viewUsername">张三</div>
            </div>
            <div class="info-item">
              <div class="info-label">用户类型</div>
              <div class="info-value" id="viewUserType">店主</div>
            </div>
            <div class="info-item">
              <div class="info-label">注册时间</div>
              <div class="info-value" id="viewRegisterTime">2023-05-15 10:30:45</div>
            </div>
            <div class="info-item">
              <div class="info-label">最后登录</div>
              <div class="info-value" id="viewLastLogin">2023-10-20 14:22:18</div>
            </div>
            <div class="info-item">
              <div class="info-label">手机号码</div>
              <div class="info-value" id="viewPhone">138****5678</div>
            </div>
            <div class="info-item">
              <div class="info-label">邮箱地址</div>
              <div class="info-value" id="viewEmail">zhangsan@example.com</div>
            </div>
            <div class="info-item">
              <div class="info-label">用户状态</div>
              <div class="info-value" id="viewStatus">正常</div>
            </div>
          </div>
          <div class="user-stats">
            <div class="stat-item">
              <div class="stat-number" id="viewFavorites">12</div>
              <div class="stat-label">收藏店铺</div>
            </div>
            <div class="stat-item">
              <div class="stat-number" id="viewCheckins">25</div>
              <div class="stat-label">打卡店铺</div>
            </div>
            <div class="stat-item">
              <div class="stat-number" id="viewReviews">8</div>
              <div class="stat-label">发表评价</div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="modal-footer">
      <button class="btn btn-primary" onclick="closeViewModal()">关闭</button>
    </div>
  </div>
</div>

<!-- 编辑用户模态框 -->
<div class="modal-overlay" id="editUserModal">
  <div class="modal-content">
    <div class="modal-header">
      <h3 class="modal-title">编辑用户信息</h3>
      <button class="modal-close" onclick="closeEditModal()">&times;</button>
    </div>
    <div class="modal-body">
      <form id="editUserForm">
        <div class="avatar-upload">
          <img src="" alt="用户头像" class="avatar-preview" id="editAvatarPreview">
          <label for="editAvatar" class="avatar-upload-btn">
            <i class="bi bi-upload"></i> 上传新头像
          </label>
          <input type="file" id="editAvatar" accept="image/*" style="display: none;" enctype="multipart/form-data">
        </div>

        <div class="form-group">
          <label class="form-label" for="editUserId">用户ID</label>
          <input type="text" class="form-input" id="editUserId" readonly>
        </div>

        <div class="form-group">
          <label class="form-label" for="editUsername">用户名</label>
          <input type="text" class="form-input" id="editUsername" required>
        </div>

        <div class="form-group">
          <label class="form-label" for="editUserType">用户类型</label>
          <select class="form-select" id="editUserType" required>
            <option value=0>普通用户</option>
            <option value=1>店主</option>
          </select>
        </div>

        <div class="form-group">
          <label class="form-label" for="editPhone">手机号码</label>
          <input type="tel" class="form-input" id="editPhone">
        </div>

        <div class="form-group">
          <label class="form-label" for="editEmail">邮箱地址</label>
          <input type="email" class="form-input" id="editEmail">
        </div>

        <div class="form-group">
          <label class="form-label" for="editStatus">用户状态</label>
          <select class="form-select" id="editStatus" required>
            <option value=0>正常</option>
            <option value=1>禁用</option>
            <option value=2>待审核</option>
          </select>
        </div>

        <div class="form-group">
          <label class="form-label" for="editDescription">个人简介</label>
          <textarea class="form-textarea" id="editDescription" placeholder="请输入用户个人简介"></textarea>
        </div>
      </form>
    </div>
    <div class="modal-footer">
      <button class="btn" onclick="closeEditModal()">取消</button>
      <button class="btn btn-primary" onclick="saveUserChanges()">保存更改</button>
    </div>
  </div>
</div>
<!-- 添加用户模态框 -->
<div class="modal-overlay" id="addUserModal">
  <div class="modal-content">
    <div class="modal-header">
      <h3 class="modal-title">添加新用户</h3>
      <button class="modal-close" onclick="closeAddModal()">&times;</button>
    </div>
    <div class="modal-body">
      <form id="addUserForm" enctype="multipart/form-data">
        <!-- 头像上传区域 -->
        <div class="avatar-upload-section">
          <div class="avatar-preview-container">
            <div class="avatar-preview-wrapper">
              <img src="" alt="用户头像预览" class="avatar-preview-img" id="addAvatarPreview">
              <div class="avatar-placeholder" id="addAvatarPlaceholder">
                <i class="bi bi-person-plus"></i>
                <span>点击上传头像</span>
              </div>
            </div>
            <div class="avatar-upload-controls">
              <label for="addAvatar" class="avatar-upload-btn">
                <i class="bi bi-cloud-upload"></i> 选择图片
              </label>
              <input type="file" id="addAvatar" accept="image/*" style="display: none;">
<!--              <input  id="addAvatar1" name="icon" style="display: none;">-->
              <div class="avatar-hint">支持 JPG、PNG 格式，最大 2MB</div>
            </div>
          </div>
        </div>

        <!-- 基本信息 -->
        <div class="form-section">
          <h4 class="section-title">基本信息</h4>
          <div class="form-row">
            <div class="form-group">
              <label class="form-label" for="addUsername">
                用户名 <span class="required">*</span>
              </label>
              <input type="text" class="form-input" id="addUsername" name="username" required
                     placeholder="请输入用户名" maxlength="20">
              <div class="form-hint">2-20个字符，支持中文、字母、数字</div>
            </div>

            <div class="form-group">
              <label class="form-label" for="addPassword">
                密码 <span class="required">*</span>
              </label>
              <input type="password" class="form-input" id="addPassword" name="password" required
                     placeholder="请输入密码" minlength="6">
              <div class="form-hint">至少6位字符</div>
            </div>
          </div>

          <div class="form-row">
            <div class="form-group">
              <label class="form-label" for="addUserType">
                用户类型 <span class="required">*</span>
              </label>
              <select class="form-select" id="addUserType" name="isOwner" required>
                <option value="">请选择用户类型</option>
                <option value="0">普通用户</option>
                <option value="1">店主</option>
              </select>
            </div>

            <div class="form-group">
              <label class="form-label" for="addStatus">
                用户状态 <span class="required">*</span>
              </label>
              <select class="form-select" id="addStatus" name="status" required>
                <option value="0">正常</option>
                <option value="1">禁用</option>
                <option value="2">待审核</option>
              </select>
            </div>
          </div>
        </div>

        <!-- 联系信息 -->
        <div class="form-section">
          <h4 class="section-title">联系信息</h4>
          <div class="form-row">
            <div class="form-group">
              <label class="form-label" for="addPhone">手机号码</label>
              <input type="tel" class="form-input" id="addPhone" name="phone"
                     placeholder="请输入手机号码" pattern="[0-9]{11}">
              <div class="form-hint">11位数字</div>
            </div>

            <div class="form-group">
              <label class="form-label" for="addEmail">邮箱地址</label>
              <input type="email" class="form-input" id="addEmail" name="email"
                     placeholder="请输入邮箱地址">
            </div>
          </div>
        </div>

        <!-- 其他信息 -->
        <div class="form-section">
          <h4 class="section-title">其他信息</h4>
          <div class="form-group">
            <label class="form-label" for="addDescription">个人简介</label>
            <textarea class="form-textarea" id="addDescription" name="description"
                      placeholder="请输入用户个人简介（可选）" maxlength="200"></textarea>
            <div class="form-hint">最多200个字符</div>
          </div>
        </div>
      </form>
    </div>
    <div class="modal-footer">
      <button class="btn btn-secondary" onclick="closeAddModal()">取消</button>
      <button class="btn btn-primary" onclick="submitAddUser()">
        <i class="bi bi-person-add"></i> 添加用户
      </button>
    </div>
  </div>
</div>
<!-- 加载动画 -->
<div id="compact-loader">
  <div class="spinner"></div>
  <span class="text">加载中...</span>
</div>

<script src="../static/js/jquery.js"></script>
<script src="../static/js/jquery.cookie.js"></script>
<script src="../static/js/user_management.js"></script>
</body>
</html>